VDoc provides a basic class which simplifies the extension classes implementation. This basic class has methods to directly access to the elements often used, such as the workflow module, the workflow instance and the resource controller.
To implement an extension class IDocumentExtension4 type, you just have to branch off the BaseDocumentExtension class. The extension class must be defined in the forms administration.
The full name is: com.axemble.vdoc.sdk.document.extensions.BaseDocumentExtension.
Methods of the BaseDocumentExtension class
public abstract class BaseDocumentExtension implements IDocumentExtension4 { // helper methods public IResourceController getResourceController(); public IWorkflowInstance getWorkflowInstance(); public IWorkflowModule getWorkflowModule(); // load public boolean onBeforeLoad(); public boolean onAfterLoad(); // subscription public boolean isOnChangeSubscriptionOn( IProperty property ); public void onPropertyChanged( IProperty property ); // save public boolean onBeforeSave(); public boolean onAfterSave(); // change stage public boolean onBeforeSubmit( IAction action ); public boolean onAfterSubmit( IAction action ); // abort public boolean onBeforeAbort(); // remind public boolean onBeforeRemind(); // close public boolean onBeforeClose(); // delegation public boolean onBeforeDelegate(); public boolean onAfterDelegate(); public boolean onBeforeDelegateTaskOnly(); public boolean onAfterDelegateTaskOnly(); public boolean onBeforeRefuseDelegation(); public boolean onAfterRefuseDelegation(); public boolean onBeforeCancelDelegation(); public boolean onAfterCancelDelegation(); // send information public boolean onBeforeSendInformation(); public boolean onAfterSendInformation(); }
Example of document extension implementation
As the following example shown, the class is much reduced. This example shows how to bring back the connected user, his superior, position the latter in a person selector field and add it the right to read on the current document.
public class GrantAccessToManager extends BaseDocumentExtension { private static final long serialVersionUID = 3457373535964512940L; public boolean onAfterLoad() { try { // get back the connected user IUser user = this.getWorkflowModule().getLoggedOnUser(); // get back the connected user manager IUser manager = user.getManager(); if ( manager == null ) { Navigator.getNavigator().showAlertBox( "The connected user has no manager." ); return false; } // position of the value from a single user selector this.getWorkflowModule().setExternalUser( this.getWorkflowInstance(), "VerificationChefDeService", manager ); // using the VDoc security manager to handle rights and add the right to read on the document ISecurityController securityController = getWorkflowModule().getSecurityController( getWorkflowInstance() ); // position a reading right securityController.addPermission( manager, Rights.Treatment.TreatmentLevel.READ_CONTENT ); } catch( WorkflowModuleException e ) { Navigator.getNavigator().processErrors( e, true ); } return super.onAfterLoad(); } }